/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fjtu.se1603.lh.dao.Impl;

import edu.fjtu.se1603.lh.dao.PetDao;
import edu.fjtu.se1603.lh.entity.Pet;
import edu.fjtu.se1603.lh.entity.PetOwner;
import edu.fjtu.se1603.lh.util.DBUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class PetImpl implements PetDao{

    @Override
    public Pet add1(int id) {
        return null;
        
    }

    @Override
    public Pet getById1(int id) {
        Pet pet=null;
        try {
            Connection con=DBUtil.getConnection();
            ResultSet rs=con.createStatement().executeQuery("select*from pet where PET_ID="+id);
            if (rs.next()) {
           pet=new Pet();
           pet.setId(rs.getInt(1));
           pet.setName(rs.getString(2));             
           System.out.println("第"+pet.getId()+"个宠物,"+"名字叫："+pet.getName());
            }
        } catch (SQLException ex) {
            Logger.getLogger(PetImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return pet;
    }
    

    @Override
    public List<Pet> getList1() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<Pet> getList1(int page, int rowcount) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public Pet getById11(int id) {
     Pet pet=null;
        try {
            Connection con=DBUtil.getConnection();
            ResultSet rs=con.createStatement().executeQuery("select*from pet where PET_ID="+id);
            if (rs.next()) {
           pet=new Pet();
           pet.setId(rs.getInt(1));
           pet.setName(rs.getString(2)); 
           pet.setTypenae (rs.getString(3));
           pet.setHealth(rs.getString(4));
           pet.setLove(rs.getString(5));
           pet.setBirthday(rs.getString(6));
           pet.setOwner_id(rs.getString(7));
           pet.setStore_id(rs.getString(8));
           pet.setPrice(rs.getString(9));
           System.out.println("序号："+pet.getId()+"我的名字叫："+pet.getName()+"     "+"我是："+pet.getTypenae()+"要购买我要花："+pet.getPrice()+"个元宝");
            }
        } catch (SQLException ex) {
            Logger.getLogger(PetImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return pet;
    }

   
  
    
}
